/*
 * @lc app=leetcode.cn id=3137 lang=golang
 *
 * [3137] K 周期字符串需要的最少操作次数
 */
package Solutions

// @lc code=start
func minimumOperationsToMakeKPeriodic(word string, k int) int {
	countMp := make(map[string]int)
	for i := 0; i < len(word); i += k {
		countMp[word[i:i+k]]++
	}
	max := 0
	for _, v := range countMp {
		if max < v {
			max = v
		}
	}
	return len(word)/k - max
}

// @lc code=end
